package com.handler.http.message.config;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author guoQ.z
 * @date 2021/1/13 14:25
 * TODO
 */
public class DecryptHttpInputMessage implements HttpInputMessage {

    private InputStream body;
    private HttpHeaders headers;

    public DecryptHttpInputMessage(HttpInputMessage inputMessage, String decryptBody) {
        this.headers = inputMessage.getHeaders();
        this.body = new ByteArrayInputStream(decryptBody.getBytes());
    }

    @Override
    public InputStream getBody() throws IOException {
        System.out.println("getBody: " + body);
        return body;
    }

    @Override
    public HttpHeaders getHeaders() {
        System.out.println("getHeaders: " + headers);
        return headers;
    }
}
